#pragma once
#include<iostream>
#include<assert.h>
using namespace std;
namespace dsh
#define max 10
{
    class queue 
    {
    public:
        queue()
            :_data(nullptr)
             ,_front(0)
             ,_rear(0)
        {
            _data = new int[max];
        }
        ~queue()
        {
            delete[] _data;
            _data = nullptr;
            _front = _rear = 0;
        }
        bool full()
        {
            return (_rear + 1) % max == _front;
        }
        void push(const int& x)
        {
            assert(!full());
            _data[_rear] = x;
            _rear = (_rear + 1) % max;
        }
        bool empty()
        {
            return _front == _rear;
        }
        void pop()
        {
            assert(!empty());
            _front = (_front + 1) % max;
        }
        int& front_data()
        {
            return _data[_front];
        }
    private:
        int* _data;
        int _front;
        int _rear;
    };
    void test_queue()
    {
        queue q;
        q.push(1);
        q.push(2);
        q.push(3);
        q.push(4);
        q.push(5);
        while (!q.empty())
        {
            cout << q.front_data() << " ";
            q.pop();
        }
        cout << endl;
    }
}
